// pages/map/driverServer/driverServer.js
const handler = require("../../../utils/function.js");
var api = require("../../../api.js"),
  QQMapWX = require("../../../utils/qqmap-wx.js"),
  app = getApp();
var demo = new QQMapWX({
  key: 'EKJBZ-72L3P-FHXDL-VSLEP-JEAGJ-JTFSD' // 必填
});
Page({
  /**
   * 页面的初始数据
   */
  data: {
    driverPosition:{
      lat: 0,
      lng: 0
    },
    fenxiaoId: '', //分销ID
    authStatus: true,
    is_GZH: false, //公众好关注
    canIUse: wx.canIUse('button.open-type.getUserInfo'), //授权登陆
    img: handler.userImg,
    markers: {},
    polyline: [{
      points: [],
      color: "#0299de",
      width: 9,
      dottedLine: false,
      arrowLine: true,
    }, ],
    startAddress: null, //开始位置
    endAddress: null, //结束位置
    longitude: null,
    latitude: null,
    orderOrMore: true, //预约和司机数量显示
    driverCount: -1,
    pageRight: 0,
    myShow: true, //显示my的页面
    zuoyou: "icon-zuoyou", //my
    avatar: "../../../images/user/icon-07.png",
    buttonText: "登录",
    username: "未登录",
    orderGoing: false,
    showTimeContainer: false,
    hours: [],
    minute: [],
    homeHandlerShow: true,
    about_time: [],
    phone: "",
    make: {},
    Hmap: '',
    left_width: 750, //右边的地图
    is_distance: false,
    price: "0.00",
    show_alert_info: false,
    userAddress: {
      location: {
        lat: '34.259430',
        lng: '108.947040'
      }
    },
    isReadProtocol: true, // 是否阅读协议
    get_order: wx.getStorageSync("get_order"), //获取订单数量

    show_bind_phone: false, //是否显示 提示绑定手机号
    scale: 15,
    isAddressText: true
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this;
    wx.getLocation({
      type: 'gcj02',
      success: function(res) {
        that.data.driverPosition.lat = res.latitude;
        that.data.driverPosition.lng = res.longitude;
        that.addressName(res.latitude + "," + res.longitude)
      },
    })
  },
  //地址你像解析
  addressName(params) {
    var that = this
    wx.request({
      url: 'https://apis.map.qq.com/ws/geocoder/v1/?l&get_poi=1', //根据经纬度转换成具体地址
      data: {
        "key": "EKJBZ-72L3P-FHXDL-VSLEP-JEAGJ-JTFSD",
        "location": params
      },
      method: 'GET',
      // header: {},
      success(res) {
        var startAddress = that.startAddress
        var data = res.data.result
        console.log(data, '---------------------')
        startAddress = {
          title: data.pois[0].title,
          address: data.pois[0].address,
          location: {
            lat: data.pois[0].location.lat,
            lng: data.pois[0].location.lng
          }
        }
        that.setData({
          startAddress,
          isAddressText: true
        })
      },
      fail: function() {
        // showToast('网络出现错误', "none")
      },
      complete: function() {}
    })
  },
  // 阅读协议
  isRead: function(e) {
    let isReadProtocol = this.data.isReadProtocol;
    this.setData({
      isReadProtocol: !isReadProtocol
    });
  },
  gotoNews: function() {
    wx.navigateTo({
      url: '/pages/user/news/news',
    })
  },
  // 取消地址信息
  clearAddressAndInfo: function() {
    let that = this;
    // 还原初始化数据
    that.setData({
      startAddress: null,
      endAddress: null,
      make: {},
      polyline: [{
        points: [],
        color: "#0299de",
        width: 9,
        dottedLine: false,
        arrowLine: true,
      }, ],
      is_distance: false,
      price: "0.00",
      show_alert_info: false,
      about_time: [],
      driverCount: -1,
    })
    // 调取地址 添加默认地址
    handler.getLatLntHandler(res => {
      that.setData({
        startAddress: res,
        userAddress: res
      })
    });
    that.get_line_and_count_distance()
  },
  // 地图图片点击事件
  controltap(e) {
    let that = this;
    console.log("map controltap", e.controlId)
    if (e.controlId === 1) {
      // this.openMyPageHandler();
      that.clearAddressAndInfo()
      wx.navigateTo({
        url: '/pages/map/my/my',
      })

    } else {
      console.log(22222222222)
      handler.getLatLntHandler((res) => {
        // console.log("一键定位", res);
        this.setData({
          userAddress: res, //开始位置
          startAddress: res
        })
      });
    }
  },
  // openMyPageHandler 打开我的页面
  openMyPageHandler: function() {
    const {
      pageRight,
      myShow
    } = this.data;
    if (myShow) {
      this.setData({
        pageRight: 620,
        left_width: 130,
        myShow: !myShow,
        controls: [{
          id: 1,
          iconPath: '../../../images/user/icon-33.png',
          position: {
            top: 144,
            left: 10,
            width: 41,
            height: 41
          },
          clickable: true
        }],
        homeHandlerShow: false
      });
    } else {
      this.setData({
        pageRight: 0,
        left_width: 750,
        myShow: !myShow,
        controls: [{
          id: 1,
          iconPath: '../../../images/user/icon-22.png',
          position: {
            left: 10,
            top: 10,
            width: 50,
            height: 50
          },
          clickable: true
        }, {
          id: 2,
          iconPath: '../../../images/user/icon-30.png',
          position: {
            top: 240,
            left: 10,
            width: 50,
            height: 50
          },
          clickable: true
        }, ],
        homeHandlerShow: true
      });
      this.changeIcon()
    }
  },
  // callPhoneHandler 帮朋友叫车功能
  callPhoneHandler: function() {
    handler.intoPageHandler("../../order/helpFriendDownloadOrder/helpFriendDownloadOrder")
  },
  // getMoreDriverHandler 需要更多为司机功能
  getMoreDriverHandler: function() {
    this.setData({
      orderOrMore: !this.data.orderOrMore
    });
  },
  // bindChange 选择司机的数量
  bindChange: function(e) {
    // console.log('司机数量', e.detail.value[0]);
    this.setData({
      driverCount: e.detail.value[0] + 1
    });
    // console.log(this.data.driverCount)
  },
  // getDriverCountHandler 获取司机的数量
  getDriverCountHandler: function() {
    this.setData({
      orderOrMore: !this.data.orderOrMore
    });
  },

  // 提交叫车订单
  create_order() {
    let that = this;
    //乘车人姓名
    wx.showLoading({})
    var name = wx.getStorageSync("relative_people") === "" ? wx.getStorageSync("user") : wx.getStorageSync("relative_people");
    app.request({
      url: api.order.place_order,
      method: 'post',
      data: {
        startAddress: JSON.stringify(this.data.startAddress),
        endAddress: JSON.stringify(this.data.endAddress),
        driver_count: this.data.driverCount === -1 ? 1 : this.data.driverCount,
        passenger_phone: name.phone,
        passenger_name: name.name,
        paid: name.replace_pay,
        type: name.type,
        about_time: this.data.about_time,
        hours: this.data.hours,
        minute: this.data.minute,
        dat: this.data.date
      },
      success: function(rs) {
        // console.log('下单成功', rs)
        // app.uploadOrder(rs.data.orderid);
        wx.hideLoading()
        if (rs.code == 1) {
          if (wx.canIUse('requestSubscribeMessage')) {
            app.request({
              url: api.message.getTmplIds,
              method: "GET",
              data: {
                type: 1
              },
              success: res => {
                wx.requestSubscribeMessage({
                  tmplIds: res.data,
                  complete: res => {
                    console.log(res)
                  }
                })
              }
            })
          }
          if (rs.data.orderid) {
            wx.setStorageSync("orderid", rs.data.orderid);
            // 清除起始地
            that.clearAddressAndInfo()
            // 创建长连接
            app.driver()
            // 跳转页面

            wx.navigateTo({
              url: '../orderAndDriverGoing/orderAndDriverGoing?order_no=' + rs.data.orderid
            })
          } else {
            handler.showToast(rs.msg, "none")
          }
        } else {
          that.open_alert_info(rs.msg)
        }
      }
    })
  },
  open_alert_info(e) {
    // console.log("open_alert_info")
    this.setData({
      show_alert_info: true,
      alert_info: e
    });
    setTimeout(() => {
      this.setData({
        show_alert_info: false
      });
    }, 2000);
  },
  // callServerHandler 一键呼叫事件
  callServerHandler: function(e) {
    let access_token = wx.getStorageSync("access_token");
    let user_info = wx.getStorageSync("user_info");
    let end = this.data.endAddress;
    let start = this.data.startAddress;
    let phone = this.userPhone;
    if (!end) {
      end = start;
    }
    if (!phone) {
      handler.showToast('请输入手机号', 'none');
      return false;
    }
    wx.showLoading({
      title: '请稍侯',
    })
    app.request({
      url: api.order.orderSelf,
      method: 'post',
      data: {
        startAddress: JSON.stringify(start),
        endAddress: JSON.stringify(end),
        driver_count: 1,
        user_phone: phone
      },
      success: function (res) {
        wx.hideLoading();
        wx.showToast({
          title: res.msg,
        })
        if (res.code == 1) {
           handler.intoPageHandler('/pages/driverOrder/orderedStatus/orderedStatus?orderstart=1&order_no=' + res.data.order.order_no);
        }
      }
    })
    console.log(start, end, phone)
    
    return;
  },
  // orderGoingHandler 订单进行中事件
  orderGoingHandler: function() {
    handler.showToast('您还没有进行中的订单', "none")
  },
  /**
   * 生命周期函数--监听页面显示
   */
  // 绘制图标
  mark_icon() {
    let that = this
    let start = this.data.startAddress;
    let end = this.data.endAddress;
    //添加图标
    let make = [];
    if (start) {
      make[0] = {
        id: 0,
        iconPath: "../../../images/user/icon-44.png",
        latitude: start.location.lat,
        longitude: start.location.lng,
        width: 40,
        height: 40
      };
      var userAddress = {
        location: {
          lat: start.location.lat,
          lng: start.location.lng
        }
      }
    }
    if (end) {
      make[1] = {
        id: 1,
        iconPath: "/images/user/icon-43.png",
        latitude: end.location.lat,
        longitude: end.location.lng,
        width: 40,
        height: 40
      };

    }
    if (start && end) {
      this.setData({
        userAddress: userAddress,
        scale: 13,
      })
    }
    that.setData({
      make: make
    });
  },

  onShow: function() {
    
  },
  getPhone (e) {
    this.userPhone = e.detail.value;
  },
  // 获取用户的位置
  getSettings: function() {
    wx.getSetting({
      success: (res) => {
        console.log(JSON.stringify(res), '初始化进入该页面')

        // res.authSetting['scope.userLocation'] == undefined    表示 初始化进入该页面
        // res.authSetting['scope.userLocation'] == false    表示 非初始化进入该页面,且未授权
        // res.authSetting['scope.userLocation'] == true    表示 地理位置授权
        if (res.authSetting['scope.userLocation'] != undefined && res.authSetting['scope.userLocation'] != true) {
          wx.showModal({
            title: '请求授权当前位置',
            content: '需要获取您的地理位置，请确认授权',
            success: function(res) {
              if (res.cancel) {
                wx.showToast({
                  title: '拒绝授权',
                  icon: 'none',
                  duration: 1000
                })
              } else if (res.confirm) {
                wx.openSetting({
                  success: function(dataAu) {
                    if (dataAu.authSetting["scope.userLocation"] == true) {
                      wx.showToast({
                        title: '授权成功',
                        icon: 'success',
                        duration: 1000
                      })
                      //再次授权，调用wx.getLocation的API
                      wx.getLocation({
                        success: function(res) {},
                      })

                    } else {
                      wx.showToast({
                        title: '授权失败',
                        icon: 'none',
                        duration: 1000
                      })
                    }
                  }
                })
              }
            }
          })
        } else if (res.authSetting['scope.userLocation'] == undefined) {
          //调用wx.getLocation的API
          wx.getLocation({
            success: function(res) {},
          })
        } else {
          //调用wx.getLocation的API
          wx.getLocation({
            success: function(res) {},
          })
        }
      }
    })
  },
  // 获取代驾人员位置
  get_driver_lat_lng: function() {
    var that = this;
    let start = this.data.startAddress;
    let end = this.data.endAddress;
    app.request({
      url: api.user.getDriverPosition,
      data: {
        lat: that.data.driverPosition.lat,
        lng: that.data.driverPosition.lng
      },
      success: function (res) {
        let makes = [],data=res.data;
      
        for(let i = 0; i < data.length; i++) {
         if (data[i].location != null) {
            makes.push({
            iconPath: "../../../images/user/icon-50.png",
            id: data[i].id,
            latitude: data[i].location.lat,
            longitude: data[i].location.lng,
            width: 60,
            height: 60,
            callout: {
              content: '' + data[i].real_name + '   ' + data[i].distance +'km',
              bgColor: '#666',
              color: '#fff',
              padding: '6',
              display: 'ALWAYS',
              borderRadius: '6'
            }
          })
         }
        }
         //添加图标
         console.log("开始图标" ,start, end)

      if (start) {

        makes[0] = {
          id: 0,
          iconPath: "../../../images/user/icon-44.png",
          latitude: start.location.lat,
          longitude: start.location.lng,
          width: 40,
          height: 40
        };
        var userAddress = {
          location: {
            lat: start.location.lat,
            lng: start.location.lng
          }
        }
      }
      if (end) {
        makes[1] = {
          id: 1,
          iconPath: "/images/user/icon-43.png",
          latitude: end.location.lat,
          longitude: end.location.lng,
          width: 40,
          height: 40
        };

      }
        that.setData({
          make: makes
        })
      }
    })
    return false ;
    setInterval(() => {
      var data = app.postlist;
      console.log(data, '代驾位置')
      var makes = [];
      // data.push(app.postlist)
      // console.log(data[0],'获取代驾人员')
      //console.log(app.postlist, '获取代驾人员')
      var i = 0;
      var make = this.data.make;
      // console.log(make, '地图标签')
      // this.mark_icon()
      if (make[0] && make[1]) {
        i = 2;
        makes.push(make[0])
        makes.push(make[1])
      }
      for (var index in data) {
        if (data[index][0] && data[index][1]) {
          makes[i] = {
            iconPath: "../../../images/user/icon-50.png",
            id: i++,
            latitude: data[index][0],
            longitude: data[index][1],
            width: 32,
            height: 32
          }
        }
      }

      // console.log(makes,'77777777777777')
      this.setData({
        make: makes
      })
    }, 10000)
  },
  // 获取路线点 并计算距离
  get_line_and_count_distance(params) {
    let that = this;
    let start = this.data.startAddress;
    let end = this.data.endAddress;
    if (start && end) {
      // 获取位置路线

      this.getPolyline(start, end)
      // console.log(start, end,'start, end')
      // 计算距离
      // this.get_distance(start, end, res => {
      //     let km_num = (res.distance.elements[0].distance / 1000).toFixed(1)
      // 
      if (!start && !end) {
        return
      }
      // 获取预计金额
      let startData = start,
          data = {
            start: JSON.stringify(start),
            end: JSON.stringify(end),
            dat: that.data.date.join(','),
            hours: that.data.hours.join(','),
            minute: that.data.minute.join(','),
            about_time: that.data.about_time.join(',')
            // mileage: km_num
          };
          
      app.request({
        url: api.order_forecast.order_forecast,
        method: "post",
        data,
        success(data) {
          that.setData({
            price: data.data.price,
            distance: data.data.actual_km,
            is_distance: true
          })
        }
      })
      // this.setData({ distance: km_num, is_distance: true });
      // })
    }
  },
  // 获取位置路线
  getPolyline: function(start, target) {
    let that = this;
    const {
      polyline
    } = this.data;
    // wx.setStorageSync("startAddress", { location: { lng: start.lng, lat: start.lat } });
    // wx.setStorageSync("endAddress", { location: { lng: target.lng, lat: target.lat } });
    const froms = start.location.lat + "," + start.location.lng + "&to=" + target.location.lat + "," + target.location.lng
    wx.request({
      url: `https://apis.map.qq.com/ws/direction/v1/driving/?from=${froms}&key=Z6RBZ-6H4CU-AV6V5-2OTIO-Q2CLZ-VMF5T`,
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: function(res) {
        // console.log(res);

        if (res.data.status != 384) {
          // 坐标解压
          var coors = res.data.result.routes[0].polyline;
          for (var i = 2; i < coors.length; i++) {
            coors[i] = coors[i - 2] + coors[i] / 1000000
          }
          // console.log(coors);
          const points = [];
          // 转化为 坐标点数组
          for (var j = 0; j < coors.length; j += 2) {
            points[points.length] = {
              longitude: coors[j + 1],
              latitude: coors[j]
            }
          }
          polyline[0].points = points;
          // console.log(polyline)

          that.setData({
            polyline
          });
        }
      },
      fail: function() {
        // showToast('网络出现错误', "none")
      }
    })
  },
  // 获取距离
  get_distance: function(start, target, callback) {
    demo.calculateDistance({
      from: {
        latitude: start.location.lat,
        longitude: start.location.lng
      },
      to: [{
        latitude: target.location.lat,
        longitude: target.location.lng
      }],
      success: function(res) {
        callback({
          distance: res.result
        })
      },
      fail: function(res) {
        callback(res)
      },
      complete: function(res) {
        // console.log(res);
      }
    });
  },
  // 用户信息事件
  /**loginHandler用户登录页面 */
  loginHandler: function(e) {
    if (this.data.buttonText === "登录") {
      handler.loginHandler((res) => {
        // console.log("用户信息事件", wx.getStorageSync("userMessage"));
        /*this.setData({
            res,
        });*/
        const that = this;
        that.getUserInfo()
      })
    } else {
      console.log('退出登录')
      app.request({
        url: api.user.loginout,
        method: 'post',
        data: {},
        success: function(rs) {
          if (rs.code == 1) {
            wx.removeStorageSync("userMessage");
            wx.removeStorageSync("phonep");
            wx.removeStorageSync("access_token");
            wx.removeStorage({
              key: 'access_token',
            })
            wx.removeStorageSync("uid");
          }
          wx.showToast({
            title: rs.msg,
            duration: 2000
          });
        }
      })
      this.setData({
        avatar: "../../../images/user/icon-07.png",
        username: "未登录",
        buttonText: "登录",
        phone: ""
      });
    }
  },
  // 授权图片展示
  getAuthorizationImg: function() {
    wx.removeStorageSync("access_token");
    let that = this;
    wx.showLoading()
    this.setData({
      authStatus: false
    })
    app.request({
      url: api.share.authorization,
      method: 'post',
      data: {},
      success: function(rs) {
        wx.hideLoading()
        // console.log(rs, '22222222222222222')
        that.setData({
          authorize: rs.data.image
        })
      }
    })
  },
  // 授权登陆
  getUserInfo: function(e) {
    let that = this;
    this.getSettings()
    wx.showLoading({})
    wx.login({
      success: res1 => {
        // console.log(res1);
        if (res1.code) {
          wx.getUserInfo({
            success: res => {
              // console.log(res);
              wx.hideLoading()
              app.request({
                url: api.user.login,
                method: 'post',
                data: {
                  code: res1.code,
                  iv: res.iv,
                  encryptedData: res.encryptedData,
                  id: that.data.fenxiaoId
                },
                success: function(rs) {
                  //获取到用户详细信息
                  // console.log(rs);
                  if (rs.code == 1) {
                    // is_binding 0 绑定手机号 1 未绑定手机号
                    var is_binding = rs.data.is_binding;
                    //is_binding=0; //测试

                    wx.showToast({
                      title: '登录成功',
                      icon: 'success',
                      duration: 2000
                    })
                    wx.setStorageSync("user_info", rs.data)
                    wx.setStorageSync("uid", rs.data.id)
                    that.setData({
                      authStatus: true,
                      is_GZH: true,
                    })
                    wx.setStorageSync("access_token", rs.data.access_token)
                    that.order_check()
                    // that.login_succ_func(rs.data)
                  } else {
                    wx.removeStorage({
                      key: 'access_token',
                    })
                    wx.removeStorage({
                      key: 'uid',
                    })
                    wx.showToast({
                      title: '登录失败',
                      icon: 'none',
                      duration: 2000
                    })
                  }
                },
              })
            }
          })
        }
      }
    })
  },
  // intoPageHandler 页面跳转
  intoPageHandler: function(e) {
    handler.intoPageHandler(e.currentTarget.dataset.skip);
  },
  //获取开始地址地址
  startAddress: function() {
    const that = this;
    wx.chooseLocation({
      success: function(res) {
        that.setData({
          startAddress: {
            title: res.name,
            address: res.address,
            location: {
              lat: res.latitude,
              lng: res.longitude
            }
          }
        })
        that.mark_icon();
        that.get_line_and_count_distance();
      },
    })
  },
  //获取结束地址地址
  endAddress: function() {
    let that = this;
    wx.chooseLocation({
      success: function(res) {
        that.setData({
          endAddress: {
            title: res.name,
            address: res.address,
            location: {
              lat: res.latitude,
              lng: res.longitude
            }
          }
        })
        // 计算路程 价格
        that.get_line_and_count_distance();
        // 绘制 起点终点图标
        that.mark_icon();
      },
    })
  },
  // relstiveServerHandler 联系客服功能
  relstiveServerHandler: function() {
    handler.callPhoneHandler(wx.getStorageSync("serverphone"));
  },
  //时间样式开始
  selectTimeShowTimeHandler: function() {
    this.setData({
      showTimeContainer: true,
      homeHandlerShow: false
    });
    this.selectTimeHandler(0, 0, 0);
  },
  // getTimeHandlerCancle 预约时间取消样式
  getTimeHandlerCancle: function() {
    this.setData({
      showTimeContainer: false,
      homeHandlerShow: true
    });
  },
  // getTimeHandlerOk 预约时间确定样式
  getTimeHandlerOk: function() {
    const {
      hours,
      minute
    } = this.data;
    // console.log(hours, minute, '1111111111111111111');
    if (!this.data.endAddress) {
      wx.showToast({
        title: '请选择目的地',
        icon: 'none'
      });
    } else {
      this.get_line_and_count_distance();
    }
    this.setData({
      now_hours: hours,
      now_minute: minute,
      showTimeContainer: false,
      homeHandlerShow: true
    });
  },
  // 绑定时间定时器
  bindTimeChange: function(e) {
    // console.log('预约时间', e.detail.value);
    this.setData({
      about_time: e.detail.value
    })
    // 今天样式
    if (e.detail.value[0] === 0 && e.detail.value[1] === 0) {
      this.selectTimeHandler(0, 0);
    } else if (e.detail.value[0] === 0 && e.detail.value[1] !== 0) {
      this.selectTimeHandler(0, e.detail.value[1]);
    }
    // 明天和后台样式
    else if (e.detail.value[0] !== 0) {
      this.selectTimeHandler(e.detail.value[0], e.detail.value[1], 0);
    }
  },
  // 选择时间函数
  selectTimeHandler: function(dateParams, hoursParams, minutesParams) {
    const {
      hours,
      minute
    } = this.data;
    const data = new Date();
    const hour = data.getHours();
    var m = data.getMinutes() + 15;
    m < 60 && hours.push(hour + "点");
    if (m > 60) {
      m -= 60;
    }

    // 今天样式
    hours.length = 0;
    minute.length = 0;
    if (dateParams === 0 && hoursParams === 0) {
      for (var i = hour + 1; i < 24; i++) {
        hours.push(i + "点");
      }
      if (parseInt(m % 10) != 0)
        var j = parseInt(m / 10) * 10 + 10
      else
        var j = parseInt(m / 10) * 10
      for (var i = j; i < 60; i += 10) {
        minute.push(i);
      }
      this.setData({
        hours,
        minute
      });
    } else if (dateParams === 0 && hoursParams !== 0) {
      hours.push(hour + "点");
      for (var i = hour + 1; i < 24; i++) {
        hours.push(i + "点");
      }
      for (var i = 0; i < 60; i += 10) {
        minute.push(i);
      }
      this.setData({
        hours,
        minute
      });
    } else if (dateParams !== 0) {
      for (var i = 0; i < 24; i++) {
        hours.push(i + "点");
      }
      for (var i = 0; i < 60; i += 10) {
        minute.push(i);
      }
      this.setData({
        hours,
        minute
      });
    }
  },
  // 修改用户和一键定位位置
  changeIcon: function() {
    const that = this;
    const {
      controls
    } = this.data;
    wx.getSystemInfo({
      success: function success(res) {
        var controlsH = res.windowWidth / 750 * 500; //计算一像素的宽度 res.windowWidth
        var map_height = res.windowHeight - controlsH;
        controls[1] = {
          id: 2,
          iconPath: '../../../images/user/icon-30.png',
          position: {
            top: map_height - 56,
            left: 10,
            width: 50,
            height: 50
          },
          clickable: true
        };
        that.setData({
          winPath: {
            w: res.windowWidth,
            h: res.windowHeight
          },
          map_height,
          controls,
        });
      }
    });
  },
  // 卸载数据
  onUnload() {
    this.setData({
      end: ""
    })
  },
  onHide() {
    this.setData({
      end: ""
    })

  },
  formSubmit: function(e) {
    var user_id = wx.getStorageSync('user_info').id;
    this.callServerHandler(null)
  },
  // 用户分享
  onShareAppMessage: function() {
    let title = app.shareAppMessage().title;
    let imageUrl = app.shareAppMessage().imageUrl;
    let desc = app.shareAppMessage().desc;
    let path = app.shareAppMessage().path;
    // console.log(app.shareAppMessage())
    return {
      title: title,
      imageUrl: imageUrl,
      desc: desc,
      path: path,
    }
  },
})